## common functions, library loading
require(reshape2)
require(plyr)
require(lattice)

##convenince function for plotting
mypdf <- function (file, .width = 7, .height = 5, do.plot = T, code) {
    pdf(file = file, height = .height, width = .width)
    if (do.plot) {
        plot(code)
    }
    else code
    dev.off()
}

##convenince function for plotting
## png for web, specify dimensions in inches
mypng <- function (file, .width = 7, .height = 5, .res=300, do.plot = T, code) {
    png(file = file, height = .height*.res, width = .width*.res, res=.res)
    if (do.plot) {
        plot(code)
    }
    else code
    dev.off()
}
